package com.dy.project.controller;

import com.dy.project.domain.CommodityOfflineUser;
import com.dy.project.service.UserService;
import com.dy.project.utils.OnlineUserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @Autowired
    private OnlineUserUtil onlineUserUtil;

    @RequestMapping("/login")
    public CommodityOfflineUser login(@RequestBody CommodityOfflineUser commodityOfflineUser) {
        CommodityOfflineUser loginUser = userService.login(commodityOfflineUser);
        onlineUserUtil.setLoginUser(loginUser);
        return loginUser;
    }
}
